package com.tmeone.erpone.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tmeone.erpone.entity.SMenu;
import com.tmeone.erpone.entity.SRoleMenu;
import com.tmeone.erpone.mapper.SMenuMapper;
import com.tmeone.erpone.service.ISMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author tmeone
 * @since 2021-04-16
 */
@Service
public class SMenuServiceImpl extends ServiceImpl<SMenuMapper, SMenu> implements ISMenuService {
    @Autowired
    private SMenuMapper functionsMapper;

    @Override
    public List<SMenu> selectFunsAll(String username) {
        List<SMenu> list = new ArrayList<>();

            List<SRoleMenu> functions = functionsMapper.selectFunsAll(username);
            for (SRoleMenu functions1: functions) {
                SMenu sMenu = functionsMapper.selectListALl(functions1.getMenuId());
                list.add(sMenu);
        }

        return list;
    }

    @Override
    public List<SMenu> selectListAll(String menuPid) {
       return functionsMapper.selectziListALl(menuPid);
    }

    @Override
    public List<String> getFunctionsIdsByRoleId(String roleId) {
        return functionsMapper.selectRoleId(roleId);
    }
}
